






<HTML>
  <HEAD>
    <SCRIPT LANGUAGE="JavaScript">
        var availableStudentArray = new Array();
        var availableParentArray = new Array();
        var assignedRecipientArray = new Array();
        var padding = "&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp";
        
        function init() { 
            insertOption(availableStudentArray, "7", "S", "Ottman", "Matthew");
insertOption(availableParentArray, "5", "P", "Ottman", "Patrick");
insertOption(availableStudentArray, "6", "S", "Steele", "Steven");
insertOption(availableParentArray, "4", "P", "Steele", "James");


          refreshAssignedRecipientFrame(top.frames.viewframe.frames["ASSIGNEDRECIPIENTVIEWPANE"]);
          refreshAvailableStudentFrame(top.frames.viewframe.frames["AVAILABLESTUDENTVIEWPANE"]);
          refreshAvailableParentFrame(top.frames.viewframe.frames["AVAILABLEPARENTVIEWPANE"]);


        }

        function insertOption(anarray, avalue, bvalue, cvalue, dvalue) {
            var aholder = -1;
            var bholder = "";
            var cholder = "";
            var dholder = "";
            for (var i = 0; i < anarray.length; i++) {
                if (avalue < anarray[i][0]) {
                    
                    aholder = anarray[i][0];
                    bholder = anarray[i][1];
                    cholder = anarray[i][2];
                    dholder = anarray[i][3];
                    anarray[i][0] = avalue;
                    anarray[i][1] = bvalue;
                    anarray[i][2] = cvalue;
                    anarray[i][3] = dvalue;
                    avalue = aholder;
                    bvalue = bholder;
                    cvalue = cholder;
                    dvalue = dholder;
                }
                else if (avalue == anarray[i][0]) {
                	// no duplicates
                	return;
                }
            }
            var bnarray = new Array();
            bnarray[0] = avalue;
            bnarray[1] = bvalue;
            bnarray[2] = cvalue;
            bnarray[3] = dvalue;
            anarray[anarray.length] = bnarray;
        }

        function removeOption(anarray, avalue) {
            for (var i = 0; i < anarray.length; i++) {
                if (avalue == anarray[i][0]) {
                    for (var j = i; j < anarray.length - 1; j++) {
                        anarray[j][0] = anarray[j+1][0];
                        anarray[j][1] = anarray[j+1][1];
                        anarray[j][2] = anarray[j+1][2];
                        anarray[j][3] = anarray[j+1][3];
                    }
                    break;
                }
            }
            
            anarray.pop(); // could try delete anarray[anarray.length - 1];
        }

        function selectStudent() {
            var selectedValues = new Array();
            var w = top.frames.viewframe.frames["AVAILABLESTUDENTVIEWPANE"];
            var d = w.document;
            var slct = d.forms[0].availableStudents;
            var counter = 0;

            while (slct[counter] && slct[counter].value == availableStudentArray[counter][0]) {
                if (slct[counter].selected) {
                    insertOption(assignedRecipientArray, availableStudentArray[counter][0], availableStudentArray[counter][1], availableStudentArray[counter][2], availableStudentArray[counter][3]);
                }
                counter = counter + 1;
            }
            counter = counter - 1;
            while (counter > -1) {
                if (slct[counter].selected) {
                    removeOption(availableStudentArray, availableStudentArray[counter][0]);
                }
                counter = counter - 1;
            }

            refreshAvailableStudentFrame(top.frames.viewframe.frames["AVAILABLESTUDENTVIEWPANE"]);
            refreshAssignedRecipientFrame(top.frames.viewframe.frames["ASSIGNEDRECIPIENTVIEWPANE"]);
        }
        
        function selectParent() {
            var selectedValues = new Array();
            var w = top.frames.viewframe.frames["AVAILABLEPARENTVIEWPANE"];
            var d = w.document;
            var slct = d.forms[0].availableParents;
            var counter = 0;

            while (slct[counter] && slct[counter].value == availableParentArray[counter][0]) {
                if (slct[counter].selected) {
                    insertOption(assignedRecipientArray, availableParentArray[counter][0], availableParentArray[counter][1], availableParentArray[counter][2], availableParentArray[counter][3]);
                }
                counter = counter + 1;
            }
            counter = counter - 1;
            while (counter > -1) {
                if (slct[counter].selected) {
                    removeOption(availableParentArray, availableParentArray[counter][0]);
                }
                counter = counter - 1;
            }

            refreshAvailableParentFrame(top.frames.viewframe.frames["AVAILABLEPARENTVIEWPANE"]);
            refreshAssignedRecipientFrame(top.frames.viewframe.frames["ASSIGNEDRECIPIENTVIEWPANE"]);
        }

        function unselectRecipient() {
            var selectedValues = new Array();
            var w = top.frames.viewframe.frames["ASSIGNEDRECIPIENTVIEWPANE"]
            var d = w.document;
            var slct = d.forms[0].assignedRecipients;
            var counter = 0;

            while (slct[counter]) {
                if (slct[counter].selected && slct[counter].value == assignedRecipientArray[counter][0]) {
                    if (assignedRecipientArray[counter][1] == "S") {
	                    insertOption(availableStudentArray, assignedRecipientArray[counter][0], assignedRecipientArray[counter][1], assignedRecipientArray[counter][2], assignedRecipientArray[counter][3]);
                    }
                    else {
	                    insertOption(availableParentArray, assignedRecipientArray[counter][0], assignedRecipientArray[counter][1], assignedRecipientArray[counter][2], assignedRecipientArray[counter][3]);
                    }
                }
                counter = counter + 1;
            }
            counter = counter - 1;
            while (counter > -1) {
                if (slct[counter].selected) {
                    removeOption(assignedRecipientArray, assignedRecipientArray[counter][0]);
                }
                counter = counter - 1;
            }

            refreshAvailableStudentFrame(top.frames.viewframe.frames["AVAILABLESTUDENTVIEWPANE"]);
            refreshAvailableParentFrame(top.frames.viewframe.frames["AVAILABLEPARENTVIEWPANE"]);
            refreshAssignedRecipientFrame(top.frames.viewframe.frames["ASSIGNEDRECIPIENTVIEWPANE"]);
        }
        
        function buildRecipientString() {
            var result = "";
            for (var i=0; i < assignedRecipientArray.length; i++) {
                if (i == 0) {
                    result = assignedRecipientArray[i][0];
                }
                else {
                    result = result + "," + assignedRecipientArray[i][0];
                }
            }
            document.forms["mailform"].ASSIGNEDRECIPIENTS.value = result;
            return true;
        }

        function refreshAvailableStudentFrame(w) {
    alert("refreshAvailableStudentFrame");
          var d = w.document;
          var pad;
          d.writeln("    <HTML><HEAD></HEAD>");
          d.writeln("");
          d.writeln("<BODY>\n");
          d.writeln("      <FORM NAME=\"availableStudentForm\" METHOD=\"POST\">\n");
          d.writeln("<SELECT NAME=\"availableStudents\" MULTIPLE=\"YES\" SIZE=\"5\">");
          for (var i=0; i<availableStudentArray.length; i++){
              if (availableStudentArray[i][0] != null) {
                  if (availableStudentArray.length < (padding.length/5)) {
                      pad = padding.substring(5 * (availableStudentArray[i][1].length), padding.length);
                  }
                  d.write("      <OPTION VALUE=\"" + availableStudentArray[i][0] + "\">" + availableStudentArray[i][2] + " " + availableStudentArray[i][3]  + pad + "</OPTION>\n");
              }
          }
          if (availableStudentArray.length == 0) {
              d.write("      <OPTION VALUE=\"\">" + padding + "</OPTION>\n");
          }
          d.writeln("</SELECT>\n");
          d.writeln("      </FORM>\n");
          d.writeln("    </BODY></HTML>\n");
          d.close();
        }

        function refreshAvailableParentFrame(w) {
    alert("refreshAvailableParentFrame");
          var d = w.document;
          var pad;
          d.writeln("    <HTML><HEAD></HEAD>");
          d.writeln("");
          d.writeln("<BODY>\n");
          d.writeln("      <FORM NAME=\"availableParentForm\" METHOD=\"POST\">\n");
          d.writeln("<SELECT NAME=\"availableParents\" MULTIPLE=\"YES\" SIZE=\"5\">");
          for (var i=0; i<availableParentArray.length; i++){
              if (availableParentArray[i][0] != null) {
                  if (availableParentArray.length < (padding.length/5)) {
                      pad = padding.substring(5 * (availableParentArray[i][1].length), padding.length);
                  }
                  d.write("      <OPTION VALUE=\"" + availableParentArray[i][0] + "\">" + availableParentArray[i][2] + " " + availableParentArray[i][3]  + pad + "</OPTION>\n");
              }
          }
          if (availableParentArray.length == 0) {
              d.write("      <OPTION VALUE=\"\">" + padding + "</OPTION>\n");
          }
          d.writeln("</SELECT>\n");
          d.writeln("      </FORM>\n");
          d.writeln("    </BODY></HTML>\n");
          d.close();
        }

        function refreshAssignedRecipientFrame(w) {
    alert("refreshAssignedRecipientFrame");
          var d = w.document;
          var pad;
          d.write("    <HTML><HEAD></HEAD><BODY>\n");
          d.write("      <FORM NAME=\"assignedRecipientForm\" METHOD=\"POST\">\n");
          d.write("<SELECT NAME=\"assignedRecipients\" MULTIPLE=\"YES\" SIZE=\"5\">");
          for (var i=0; i<assignedRecipientArray.length; i++){
              if (assignedRecipientArray[i][0] != null) {
                  if (assignedRecipientArray[i][0].length < (padding.length/5)) {
                      pad = padding.substring(5 * (assignedRecipientArray[i][0].length), padding.length);
                  }
                  d.write("      <OPTION VALUE=\"" + assignedRecipientArray[i][0] + "\">" + assignedRecipientArray[i][2] + assignedRecipientArray[i][3] + pad + "</OPTION>\n");
              }
          }
          if (assignedRecipientArray.length == 0) {
              d.write("      <OPTION VALUE=\"\">" + padding + "</OPTION>\n");
          }
          d.write("</SELECT>\n");
          d.write("      </FORM>\n");
          d.write("    </BODY></HTML>\n");
          d.close();
        }


		function cancelForm() {
			document.forms[0].LINKCLICKED.value = "CANCEL";
			document.forms[0].submit();
		}

    </SCRIPT>
  </HEAD>
  <BODY >
    <FORM NAME="mailform" METHOD="POST" onSubmit="buildRecipientString()">
      <INPUT TYPE="HIDDEN" NAME="ASSIGNEDRECIPIENTS" VALUE="">
      <INPUT TYPE="HIDDEN" NAME="CURRENT" VALUE="SUBFRAME">
      <INPUT TYPE="HIDDEN" NAME="TOKEN" VALUE="1069042985359">
      <INPUT TYPE="HIDDEN" NAME="PARAM" VALUE="">
      <INPUT TYPE="HIDDEN" NAME="CLASSNUM" VALUE="0">
      <INPUT TYPE="HIDDEN" NAME="LINKCLICKED" VALUE="">

  <INPUT TYPE="HIDDEN" NAME="CT_FROM_ID" VALUE="1">
<INPUT TYPE="HIDDEN" NAME="FORMFROMPARENT" VALUE="FALSE">
<INPUT TYPE="HIDDEN" NAME="FORMFROMSTUDENT" VALUE="TRUE">
<INPUT TYPE="HIDDEN" NAME="CLASS_ASSIGNED_ID" VALUE="4">
<TABLE>
<TR>
<TD WIDTH="60">
&nbsp;<B>To:&nbsp;&nbsp;</B></TD>
            <TR>
                <TD COLSPAN="5">
                    <TABLE>
                        <TR>
                            <TD ALIGN="CENTER" COLSPAN="2"><H3>Students</H3></TD>
                            <TD>&nbsp</TD>
                            <TD ALIGN="CENTER" COLSPAN="2"><H3>Parents</H3></TD>
                            <TD>&nbsp</TD>
                            <TD ALIGN="CENTER" COLSPAN="2"><H3>Recipients</H3></TD>
                        </TR>
                        <TR>
                            <TD ALIGN="CENTER" COLSPAN="2">
        <iframe id='AVAILABLESTUDENTVIEWPANE' src="" style="width: 200; height: 102; margin: 0px; text-align: center;border: solid;border-color: silver" marginWidth=0 marginHeight=0 FRAMEBORDER=0 SCROLLING="auto">
          <TEXTAREA ROWS="28" COLS="40">HI</TEXTAREA>
        </iframe>
</TD>
                            <TD>&nbsp</TD>
                            <TD ALIGN="CENTER" COLSPAN="2">
        <iframe id='AVAILABLEPARENTVIEWPANE' src="" style="width: 200; height: 102; margin: 0px; text-align: center;border: solid;border-color: silver" marginWidth=0 marginHeight=0 FRAMEBORDER=0 SCROLLING="auto">
          <TEXTAREA ROWS="28" COLS="40">HI</TEXTAREA>
        </iframe>
</TD>
                            <TD>&nbsp;&nbsp;<INPUT TYPE="BUTTON" VALUE="" onClick='unselectRecipient()'>&nbsp;&nbsp;<BR>
                                &nbsp;<BR>
                                &nbsp;&nbsp;<INPUT TYPE="BUTTON" VALUE="Parent -->" onClick='selectParent()'>&nbsp;&nbsp;
                                &nbsp;<BR>
                                &nbsp;&nbsp;<INPUT TYPE="BUTTON" VALUE="Student -->" onClick='selectStudent()'>&nbsp;&nbsp;</TD>
                            <TD ALIGN="CENTER" COLSPAN="2">
        <iframe id='ASSIGNEDRECIPIENTVIEWPANE' src="" style="width: 200; height: 102; margin: 0px; text-align: center;border: solid;border-color: silver" marginWidth=0 marginHeight=0 FRAMEBORDER=0 SCROLLING="auto">
          <TEXTAREA ROWS="28" COLS="40">HI</TEXTAREA>
        </iframe>
                            </TD>
                        </TR>
                    </TABLE>
                </TD>
            </TR>
<TR>
<TD>
&nbsp;<B>From:&nbsp;&nbsp;</B></TD>
<TD>
Jim Jones
</TR>
<TR>
<TD>
&nbsp;<B>Subject:&nbsp;&nbsp;</B></TD>
<TD>
<INPUT TYPE="TEXT" NAME="MSG_SUBJECT" VALUE="" SIZE="82"></TD>
</TR>
</TABLE>
<hr>
<TEXTAREA NAME="MSG_BODY" COLS="82" ROWS="11" VALUE="" SCROLLING='NO'>
</TEXTAREA><BR>
<CENTER><INPUT TYPE="SUBMIT" NAME="BUTTONCLICKED" VALUE="Send">  
<INPUT TYPE="SUBMIT" NAME="BUTTONCLICKED" VALUE="Cancel"></CENTER>

    </FORM>
  </BODY>
</HTML>